//
//  Sgr_macro.h
//  sagittarius
//
//  Created by li hongdan on 12-11-22.
//  Copyright (c) 2012年 sagittarius. All rights reserved.
//

#ifndef sagittarius_Sgr_macro_h
#define sagittarius_Sgr_macro_h

#define SGR_SINGLETION(__clazz) \
+ (__clazz *)sharedInstance;

#define SGR_DEF_SINGLETION(__clazz) \
+ (__clazz *)sharedInstance \
{\
static dispatch_once_t once; \
static __clazz * __singletion;\
dispatch_once(&once,^{__singletion = [[__clazz alloc] init];});\
return __singletion;\
}

#define sgrSafeMainThread(block)  if ([NSThread isMainThread ]) {\
block();\
}else{\
dispatch_async(dispatch_get_main_queue(), block);\
}\

#define DEGREES_TO_RADIANS(x) (x)/180.0*M_PI
#define RADIANS_TO_DEGREES(x) (x)/M_PI*180.0
#define RGB(r,g,b)  [UIColor colorWithRed:r/255.f green:g/255.f blue:b/255.f alpha:1.f]
#define _safeStr(a) (a?a:@"")


#define _isStrNULL(a) (!a || [a length]==0  || ![a isKindOfClass:[NSString class]])
#define _isStrNotNull(a) (a && [a isKindOfClass:[NSString class]] && [a length])


#define sgrpngbundle(imageName,type) [[NSBundle mainBundle] pathForResource:imageName ofType:type]
#define sgrUIImageFile(imageName) [UIImage imageWithContentsOfFile:sgrpngbundle(imageName,@"png")]
#define sgrUIImageJPGFile(imageName) [UIImage imageWithContentsOfFile:sgrpngbundle(imageName,@"jpg")]

#if ! __has_feature(objc_arc)
#else
#endif


#ifdef DEBUG
#define trace(format,...) NSLog(format,##__VA_ARGS__)
#else
#define trace(format,...)
#endif

#endif
